/* eslint-disable */
import pkg from '../../package'

const debug = {}
const DEBUG = pkg.name + '_DEBUG'
const INIT_AA10 = pkg.name + '_INIT_AA10'

debug.log = function (...msg) {
  if (this.isDebug) {
    console.log(...msg)
  }
}

debug.error = function (...msg) {
  if (this.isDebug) {
    console.error(...msg)
  }
}

debug.init = function () {
  if (this.isDebug()) document.write(`<script>new VConsole()<\/script>`)
}

debug.isDebug = function () {
  if (localStorage.getItem(DEBUG) && localStorage.getItem(DEBUG) === 'true') {
    return true
  }
}

debug.setDebug = function (flag) {
  localStorage.setItem(DEBUG, flag)
}

debug.isInitAA10 = function () {
  if (localStorage.getItem(INIT_AA10) && localStorage.getItem(INIT_AA10) === 'true') {
    return true
  } else {
    return false
  }
}

debug.setInitAA10 = function (flag) {
  localStorage.setItem(INIT_AA10, flag)
}

export default debug
